<div class="main-content">
    <div class="section__content section__content--p20">
        <div class="container-fluid">
            <div class="row m-b-30">
                <div class="col-lg-12">
                    <div class="overview-wrap">
                        <h2 class="title-1">查看留言</h2>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="table-responsive table--no-card m-b-30">
                        <table class="table table-borderless table-striped table-earning ">
                                <thead>
                                <tr>
                                    <th>作者</th>
                                    <th>标题</th>
                                    <th>内容</th>
                                    <th>已读</th>
                                    <th>模块</th>
                                    <th>提交时间</th>
                                    <th>工具</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php
                                if (sizeof($list) > 0) {
                                    foreach ($list as $m) {
                                        ?>
                                        <tr>
                                            <td><?php echo $m->user->username; ?></td>
                                            <td><?php echo $m['title']; ?></td>
                                            <td><?php echo $m['content']; ?></td>
                                            <td><?php
                                                if ($m['haveread'] == 0) {
                                                    echo "否";
                                                } else {
                                                    echo "是";
                                                }
                                                ?></td>

                                            <td><?php echo $m->module->category; ?></td>
                                            <td><?php echo $m['createtime']; ?></td>
                                            <td>
                                                <button type="button" class="btn btn-primary btn-sm" onclick="showedit(<?php echo $m['message_id']; ?>)">编辑</button>
                                            </td>
                                        </tr>
                                        <?php
                                    }
                                }
                                ?>
                                </tbody>
                            </table>
                    </div>
                </div>
            </div>
            <div class="row ">
                <div class="col-lg-12 text-center">
                    <div style="display: inline-block;"><?php
                        $this->widget('CLinkPager', array(
                                'header' => '',
                                'firstPageLabel' => '首页',
                                'lastPageLabel' => '末页',
                                'prevPageLabel' => '上一页',
                                'nextPageLabel' => '下一页',
                                'pages' => $pages,
                                "selectedPageCssClass"=>'active',
                                'htmlOptions' => Array('class' => 'pagination pagination_customize')
                            )
                        );
                        ?></div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>

    function showedit(id) {
        window.location.href = "index.php?r=admin/message/showedit&id=" + id;
    }
    function del(id) {
        $("#confirmModal_text").text('是否删除消息？');
        $("#confirmModalButton").bind("click",function () {
            $.get('index.php?r=admin/message/del', {id: id}, function (result) {
                if (result.type == true) {
                    window.location.reload();
                } else {
                    alert(result.message);
                }
            }, 'json');
        });
    }
</script>